﻿using ClassLibrary.SignalType.SynchronousTransportModuleLevel1.VirtualContainer;


namespace ClassLibrary.SignalType
{
    public static class DataUtils
    {
        public static Vc4 ConstructVC4(DataPackage data)
        {
            Vc vc = null;
            int dataLength = data.Data.Length;
            VCType[] vcTypeValues = new VCType[] { VCType.VC12, VCType.VC2, VCType.VC3 };
            foreach (VCType vcType in vcTypeValues)
            {
                int vcLength = VirtualContainer.VcLengthDictionary[vcType];
                if (vcLength >= dataLength)
                {
                    vc = new Vc(vcType, data);
                }
            }

            Vc4 vc4;
            if (vc == null)
            {
                vc4 = new Vc4(data);
            }
            else
            {
                vc4 = new Vc4(new Vc[] { vc });
            }

            return vc4;
        }
    }
}
